package com.assignwork.modules.corp;

import com.assignwork.dto.CorpCargoSearchDTO;
import com.assignwork.dto.CorpCargoSubmitDTO;
import com.assignwork.service.ICorpCargoService;
import com.assignwork.vo.CorpCargoListVO;
import com.assignwork.vo.CorpCargoPageVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ClassName CorpCargoController
 * @Description
 * @Author dujianyu
 * @Date 2023/8/23 8:22
 */
@RestController
@AllArgsConstructor
@RequestMapping("corp/corpCargo")
public class CorpCargoController extends BladeController {

    private ICorpCargoService service;

    @GetMapping("/page")
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "分页", notes = "传入dto")
    public R<IPage<CorpCargoPageVO>> page(CorpCargoSearchDTO dto, Query query) {
        return R.data(service.selectCorpCargoPage(dto, Condition.getPage(query)));
    }

    @GetMapping("/list")
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "列表", notes = "传入dto")
    public R<List<CorpCargoListVO>> list(CorpCargoSearchDTO dto) {
        return R.data(service.selectCorpCargoList(dto));
    }

    @PostMapping("submit")
    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "新增或修改", notes = "传入dto")
    public R<Boolean> submitShipAgent(@RequestBody CorpCargoSubmitDTO dto) {
        return R.status(service.submitCorpCargo(dto));
    }

    @PostMapping("/remove")
    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "删除", notes = "传入id")
    public R<Boolean> remove(@ApiParam(value = "主键集合", required = true) @RequestParam String id) {
        return R.status(service.deleteLogic(Func.toLongList(id)));
    }

    @GetMapping("/pinyinSet")
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "设置拼音", notes = "设置拼音")
    public R<Boolean> pinyinSet() {
        return R.status(service.pinyinSet());
    }

}
